﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BUS;
using DTO;
namespace CDT_CSDLNC
{
    public partial class ucXacNhanNguoiMua : UserControl
    {
        public ucXacNhanNguoiMua()
        {
            InitializeComponent();
        }

        public string maKhachHang;
      
        private void ucXacNhanNguoiMua_Load(object sender, EventArgs e)
        {
            DataTable dt = KhachHangBUS.ThongTinKhachHang(maKhachHang);
            tbHoTenNguoiMua.Text = dt.Rows[0]["HoTen"].ToString();
            tbDienThoaiNguoiMua.Text = dt.Rows[0]["DienThoai"].ToString();
            tbEmailNguoiMua.Text = dt.Rows[0]["Email"].ToString();
            rtbDiaChiNguoiMua.Text = dt.Rows[0]["DiaChi"].ToString();

            tbHoTenCapNhat.Text = dt.Rows[0]["HoTen"].ToString();
            tbDienThoaiCapNhat.Text = dt.Rows[0]["DienThoai"].ToString();
            tbEmailCapNhat.Text = dt.Rows[0]["Email"].ToString();
            rtbDiaChiCapNhat.Text = dt.Rows[0]["DiaChi"].ToString();
        }

        private void cbTrungThongTin_CheckedChanged(object sender, EventArgs e)
        {
            bool kq = !(cbTrungThongTin.Checked);
            tbHoTenCapNhat.Enabled = kq;
            tbDienThoaiCapNhat.Enabled = kq;
            tbEmailCapNhat.Enabled = kq;
            rtbDiaChiCapNhat.Enabled = kq;
        }

        private void XuLyKichBan()
        {
            frmMain main = (frmMain)this.ParentForm;
            int flag = main.flag;
            switch (flag)
            {
                case 1:
                    main.kb1_buoc = 5;
                    main.KichBan1();
                    break;
                case 2:
                    main.kb2_buoc = 6;
                    main.KichBan2();
                    break;
                case 3:
                    main.kb3_buoc = 5;
                    main.KichBan3();
                    break;
                case 4:
                    main.kb4_buoc = 5;
                    main.KichBan4();
                    break;
            }
        }

        private void btnXacNhan_Click(object sender, EventArgs e)
        {
            if (cbTrungThongTin.Checked == true)
            {
                XuLyKichBan();
            }
            else
            { 
            }
        }
    }
}
